// pages/hotel/index.js
const App = getApp();
Page({
  /**
   * 组件的属性列表
   */

  /**
   * 组件的初始数据
   */
  data: {
    hotelList: [],
    shopname: ''
  },
  onLoad() {
    this.getHotel()
  },
  onShow() {
    this.getHotel()
  },
  bindHideShopname(e) {
    this.setData({
      shopname: e.detail.value
    })
  },
  /**
   * 组件的方法列表
   */
  getMajor(e) {
    wx.navigateTo({
      url: '/pages/major/index?shop_id=' + e.currentTarget.dataset.shop_id,
    })
  },
  getHotel() {
    let app = this
    App._get('shop/lists', {
      longitude: wx.getStorageSync('longitude'),
      latitude: wx.getStorageSync('latitude'),
      shopname: app.data.shopname,
      province_id: wx.getStorageSync('province_id'),
      city_id: wx.getStorageSync('city_id')
    }, result => {
      // 设置顶部导航栏栏
      // _this.setPageBar(result.data.page);
      let detail = result.data.list
      detail.forEach(el => {
        const text = el.summary
        const chars = text.split(',');
        el.summarys = chars
      })
      app.setData({
        hotelList: detail
      });

    });
  },
  return () {
    this.setData({
      shopname: ''
    })
    this.getHotel()
  }
})